﻿using LPBToolsLib;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 电子票存档工具
{
    internal static class Program
    {
        static AppRunConfig DBServerCFG { get; set; }
        const string MutexStr = "财务电子票据存档工具-20240726";
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            bool runone;
            Mutex tMutex = new Mutex(true, MutexStr,out runone); try
            {
                if (runone)
                {

                    string tempPath = "temp\\";
                    string currentDirectory = Directory.GetCurrentDirectory() + "\\";
                    if (!Directory.Exists(currentDirectory + tempPath))
                    {
                        Directory.CreateDirectory(currentDirectory + tempPath);
                    }
                    //currentDirectory = System.Environment.CurrentDirectory;
                    JSONINISettings tConfig = new JSONINISettings(currentDirectory + "HCEBills.ini");
                    DBServerCFG = new AppRunConfig(tConfig, "EBillsDBSer");

                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    FLogin tLogin = new FLogin(DBServerCFG);
                    if (tLogin.ShowDialog() == DialogResult.Yes)
                        Application.Run(new FEBillQuery(DBServerCFG));
                }
            }
            finally
            {
                tMutex.ReleaseMutex();
            }

        }
        
    }
}
